import { addNameSpace } from './util'

const NAME_SPACE = 'SEND'

const addPrefix = addNameSpace(NAME_SPACE)

// 签名前置
export const SET_SIGN_FRONT = addPrefix('SET_SIGN_FRONT')

// 签名后置
export const SET_SIGN_BACK = addPrefix('SET_SIGN_BACK')

export const SET_SIGN_BACK_DELAY = addPrefix('SET_SIGN_BACK_DELAY')

// 导入文件
export const IMPORT_FILE = addPrefix('IMPORT_FILE')

// 导入文件成功
export const IMPORT_FILE_SUCCESS = addPrefix('IMPORT_FILE_SUCCESS')

// 导入文件失败
export const IMPORT_FILE_FAIL = addPrefix('IMPORT_FILE_FAIL')

// 改变运营商选择类型
export const CHANGE_PHONE_SELECT_TYPES = addPrefix('CHANGE_PHONE_SELECT_TYPES')

// 获取签名
export const GET_SIGN_DATA = addPrefix('GET_SIGN_DATA') 

// 获取签名成功
export const GET_SIGN_DATA_SUCCESS = addPrefix('GET_SIGN_DATA_SUCCESS')

// 获取签名失败
export const GET_SIGN_DATA_FAIL = addPrefix('GET_SIGN_DATA_FAIL')

// 设置号码
export const SET_PHONES = addPrefix('SET_PHONES')

// 设置签名
export const SET_SIGN = addPrefix('SET_SIGN')

// 设置短信内容
export const SET_MESSAGE_CONTENT = addPrefix('SET_MESSAGE_CONTENT')

// 发送
export const SEND = addPrefix('SEND')

// 发送成功
export const SEND_SUCCESS = addPrefix('SEND_SUCCESS')

// 发送失败
export const SEND_FAIL = addPrefix('SEND_FAIL')

export const setSignFront = () => ({ type: SET_SIGN_FRONT })

export const setSignBack = () => ({ type: SET_SIGN_BACK })

export const setSignBackDelay = () => ({ type: SET_SIGN_BACK_DELAY })

export const importFile = (file) => ({ type: IMPORT_FILE, file })

export const importFileSuccess = (fileData, fileName) => ({ type: IMPORT_FILE_SUCCESS, fileData, fileName })

export const importFileFail = () => ({ type: IMPORT_FILE_FAIL })

export const changePhoneSelectTypes = (phoneSelectTypes) => ({ type: CHANGE_PHONE_SELECT_TYPES, phoneSelectTypes })

export const getSignData = () => ({ type: GET_SIGN_DATA })

export const getSignDataSuccess = (signData) => ({ type: GET_SIGN_DATA_SUCCESS, signData })

export const getSignDataFail = () => ({ type: GET_SIGN_DATA_FAIL })

export const setPhones = (phones) => ({ type: SET_PHONES, phones })

export const setSign = (sign) => ({ type: SET_SIGN, sign })

export const setMessageContent = (messageContent) => ({ type: SET_MESSAGE_CONTENT, messageContent })

export const send = (params) => ({ type: SEND, params })

export const sendSuccess = () => ({ type: SEND_SUCCESS })

export const sendFail = () => ({ type: SEND_FAIL })

export default {
  setSignFront,
  setSignBack,
  setSignBackDelay,
  importFile,
  importFileSuccess,
  importFileFail,
  changePhoneSelectTypes,
  getSignData,
  getSignDataSuccess,
  getSignDataFail,
  setPhones,
  setSign,
  setMessageContent,
  send,
  sendSuccess,
  sendFail,
}